<?if($this->is_public == 0 && !$this->hasAccess($this->board_uid)): echo $this->action('denied', 'error'); else:?>

	<script type="text/javascript">
	var ajax_load_xs	= "<img src='<?=$this->baseUrl()?>/static/gfx/ajax-loader_xs.gif' alt='loading...' />";
	var ajax_load		= "<img src='<?=$this->baseUrl()?>/static/gfx/ajax-loader.gif' alt='loading...' />";
	
	function rate(uid, val) {
		document.getElementById("post_rating_result_"+uid).innerHTML = ajax_load_xs;
		$.get("<?=$this->url(array('controller' => 'rate', 'action' => 'request'), 'default', true)?>", { uid: uid, val: val }, function(data) {
			document.getElementById("post_rating_result_"+uid).innerHTML = data
		});
	}
	
	function editTitle(uid) {
		value = prompt('<?=$this->translate->_('topic_new_title')?>');
		if(value) {
			document.getElementById("topic_name").innerHTML = ajax_load;
			$.get("<?=$this->url(array('controller' => 'threads', 'action' => 'settitle'), 'default', true)?>", { uid: uid, val: value }, function(data) {
				document.getElementById("topic_name").innerHTML = data
			});
		}
	}

	function threadNotify(thread_uid, user_uid, status)
	{
		if(thread_uid != '' && user_uid != '')
		{
			$("#thread_watch").html(ajax_load);
			
			if(status == 'activate' || status == 'stop')
			{
				$.get("<?=$this->url(array('controller' => 'threads', 'action' => 'watch'), 'default', true)?>", { thread_uid: thread_uid, user_uid: user_uid, status: status }, function(data) {
					$("#thread_watch").html(data);
				});
			}
		}
	}

	function toggleLogin() {
		if ($("#thread_login").is(":hidden")) 
		{
			$("#thread_login").fadeIn("slow");
		} 
		else 
		{
			$("#thread_login").fadeOut("slow");
		}
	}
	</script>
	
	<h1>Post-Übersicht</h1>
	
	<p><a href="<?=$this->url(array('controller' => 'index'),'index', true)?>">Forum</a><?=$this->getRootline($this->board_uid, $this->thread_uid)?> <?if($this->isMod($this->auth_uid, $this->board_uid)):?><a href="javascript:editTitle(<?=$this->thread_uid?>);"><img src="<?=$this->baseUrl()?>/static/gfx/icons/pencil.png" alt="<?=$this->translate->_('topic_edit')?>" title="<?=$this->translate->_('topic_edit')?>" /></a><?endif;?></p>
	
	<p>
		<?if($this->auth):?>
			<?if($this->CheckNotify($this->thread_uid, $this->auth_uid)):?>
				<span id="thread_watch"><img src="<?=$this->baseUrl()?>/static/gfx/icons/note_delete.png" style="position:relative; top:3px;" /> <a href="javascript:threadNotify(<?=$this->thread_uid?>,<?=$this->auth_uid?>,'stop');"><?=$this->translate->_('post_notify_2')?></a></span> -
			<?else:?>
				<span id="thread_watch"><img src="<?=$this->baseUrl()?>/static/gfx/icons/note_add.png" style="position:relative; top:3px;" /> <a href="javascript:threadNotify(<?=$this->thread_uid?>,<?=$this->auth_uid?>,'activate');"><?=$this->translate->_('post_notify_1')?></a></span> -
			<?endif;?>
		<?endif;?> 
		<img src="<?=$this->baseUrl()?>/static/gfx/icons/page_edit.png" style="position:relative; top:3px;" /> <a href="#new_post"><?=$this->translate->_('post_add_post')?></a>
	</p>
	
	<?if($this->isMod($this->auth_uid, $this->board_uid)):?>
	<p>
		<form action="<?=$this->baseUrl()?>/posts/mode/uid/<?=$this->thread_uid?>" method="post" onchange="this.submit();">
			<input type="hidden" name="board_uid" value="<?=$this->board_uid?>" />
			<?=$this->translate->_('topic_mod')?>
			<select name="mod[]">
				<option value="" selected="selected"><?=$this->translate->_('topic_choose')?></option>
				<?if($this->closed == 1):?>
					<option value="open"><?=$this->translate->_('topic_open')?></option>
				<?else:?>
					<option value="close"><?=$this->translate->_('topic_close')?></option>
				<?endif;?>
				
				<?if($this->sticky == 0):?>
					<option value="sticky"><?=$this->translate->_('topic_sticky')?></option>
				<?else:?>
					<option value="unsticky"><?=$this->translate->_('topic_unsticky')?></option>
				<?endif;?>
				
				<?if($this->deleted == 0):?>
					<option value="delete"><?=$this->translate->_('topic_delete')?></option>
				<?else:?>
					<option value="undelete"><?=$this->translate->_('topic_undelete')?></option>
				<?endif;?>
			</select>
		</form>
	</p>
	<br />
	<?endif;?>
	
	<?=$this->paginationControl($this->result, 'Sliding', 'pagination_control.phtml', array('route' => 'threads_p', 'uid' => $this->thread_uid))?>
	
	<?if($this->result_count > 0):?>
		<table summary="boards" class="table_posts"> 
		<tr>
			<th width="150px;"><?=$this->translate->_('post_author')?></th>
			<th><?=$this->translate->_('post_text')?></th>
		</tr>
		
		<?foreach($this->result AS $result):?>
			<?if($result['is_deleted'] == 1):?>
				<tr>
					<td colspan="2"><a href="javascript:toggle(<?=$result['uid']?>);"><?=$this->translate->_('post_deleted')?></a></td>
				</tr>
			<?endif;?>
			
			<?if($this->posts_rating > 0 && $this->getRating($result['uid']) < 0 && abs($this->getRating($result['uid'])) >= $this->posts_rating):?>
				<?$is_bad_post = true;?>
				<tr>
					<td colspan="2" class="bad_post"><a href="javascript:toggle(<?=$result['uid']?>);"><img src="<?=$this->baseUrl()?>/static/gfx/icons/error.png" title="<?=$this->translate->_('post_hidden')?>" /> <?=$this->translate->_('post_hidden')?></a></td>
				</tr>
			<?else:?>
				<?$is_bad_post = false;?>
			<?endif;?>
		
			<tr id="row1<?=$result['uid']?>" <?if($result['is_deleted'] == 1 OR $is_bad_post):?>style="display:none;"<?endif;?>>
				<td class="posts_author top">
					<?=$this->partial('posts/author.phtml', array('author_uid' => $this->author_uid, 'result' => $result, 'translate' => $this->translate))?>
				</td>
				<td class="posts_text">
					<?=$this->partial('posts/author_message.phtml', array('result' => $result, 'translate' => $this->translate))?>
				</td>
			</tr>
			<tr id="row2<?=$result['uid']?>" <?if($result['is_deleted'] == 1 OR $is_bad_post):?>style="display:none;"<?endif;?>>
				<td class="posts_date middle"><img style="position:relative;top:4px;" src="<?=$this->baseUrl()?>/static/gfx/icons/time.png" alt="<?=$this->translate->_('post_posted')?>" /> <?=$this->datetime($result['create_date'], 'dd.MM.yy, HH:m', true)?></td>
				<td class="posts_buttons">
					
					<?if($this->allowRating == 1 && $this->auth):?>
					<p style="display:inline-block; padding:0px; margin:0px; float:left;">
						<a href="javascript:rate(<?=$result['uid']?>,'up');"><img style="position:relative; top:4px;" src="<?=$this->baseUrl()?>/static/gfx/icons/thumb_up.png" alt="" title="" /></a> 
						<a href="javascript:rate(<?=$result['uid']?>,'down');"><img style="position:relative; top:4px;" src="<?=$this->baseUrl()?>/static/gfx/icons/thumb_down.png" alt="" title="" /></a> 
						<?if($this->getRating($result['uid']) < 0):?>
							<span style="color:red; font-weight:bold;"  id="post_rating_result_<?=$result['uid']?>"><?=$this->getRating($result['uid'])?></span>
						<?elseif($this->getRating($result['uid']) > 0):?>
							<span style="color:green; font-weight:bold;" id="post_rating_result_<?=$result['uid']?>">+<?=$this->getRating($result['uid'])?></span>
						<?else:?>
							<span id="post_rating_result_<?=$result['uid']?>"><?=$this->getRating($result['uid'])?></span>
						<?endif;?>
					</p>
					<?endif;?>
					
					<p style="display:inline-block; padding:0px; margin:0px; float:right;">
						<?if($this->auth_uid == $result['user_uid'] OR $this->isMod($this->auth_uid, $this->board_uid)):?>
							<a href="<?=$this->url(array('controller' => 'post', 'action' => 'edit', 'uid' => $result['uid']), 'post_edit', true)?>">
								<img src="<?=$this->baseUrl()?>/static/gfx/icons/page_edit.png" alt="<?=$this->translate->_('post_edit')?>" title="<?=$this->translate->_('post_edit')?>" />
							</a>
						<?endif;?>
						
						<?if($this->isMod($this->auth_uid, $this->board_uid)):?>
							<a href="<?=$this->url(array('controller' => 'post', 'action' => 'delete', 'uid' => $result['uid']), 'post_delete', true)?>">
								<img src="<?=$this->baseUrl()?>/static/gfx/icons/page_delete.png" alt="<?=$this->translate->_('post_delete')?>" title="<?=$this->translate->_('post_delete')?>" />
							</a>
							
							<a href="<?=$this->url(array('controller' => 'moderation', 'action' => 'ban', 'uid' => $result['uid']), 'default', true)?>">
								<img src="<?=$this->baseUrl()?>/static/gfx/icons/page_user.gif" alt="<?=$this->translate->_('post_ban')?>" title="<?=$this->translate->_('post_ban')?>" />
							</a>
						<?endif;?>
						
						<a href="javascript:quote(<?=$result['uid']?>);">
							<img src="<?=$this->baseUrl()?>/static/gfx/icons/user_comment.png" alt="<?=$this->translate->_('post_quote')?>" title="<?=$this->translate->_('post_quote')?>" />
						</a>
							
						<?if($this->auth):?>
							<a href="<?=$this->url(array('controller' => 'ticket', 'action' => 'add'), 'ticket_add', true)?>">
								<img src="<?=$this->baseUrl()?>/static/gfx/icons/report_user.png" alt="<?=$this->translate->_('post_report')?>" title="<?=$this->translate->_('post_report')?>" />
							</a>
						<?endif;?>
					</p>
				</td>
			</tr>
		<?endforeach;?>
		
		<?if($this->closed == 0):?>
			<tr>
				<?if($this->auth OR $this->allow_guest_posts == 1):?>
				<td class="new_post"><a name="new_post"></a><?=$this->translate->_('form_reply_on_post')?></td>
				<td class="new_post_form">
					<?if($this->pubPosts == 0):?>
						<p class="notice"><?=$this->translate->_('nonpublic_notice_post')?></p>
					<?endif;?>
					<form id="new_post" enctype="application/x-www-form-urlencoded" action="" method="post">
						<?=$this->partial('editor.phtml', array('captcha' => $this->captcha, 'translate' => $this->translate))?>
					</form>
				</td>
				<?else:?>
					<td class="center thread_login" colspan="2"><a name="new_post"></a><?=$this->translate->_('post_login')?></td></tr><tr id="thread_login" style="display:none;">
					<td colspan="2"><?=$this->partial('index/login.phtml', array('translate' => $this->translate))?></td>
				<?endif;?>
			</tr>
		<?else:?>
			<tr>
				<td colspan="2" class="center thread_closed"><a name="new_post"></a><?=$this->translate->_('thread_closed')?></td>
			</tr>
		<?endif;?>
		
		</table>
		<br />
		<?=$this->paginationControl($this->result, 'Sliding', 'pagination_control.phtml', array('route' => 'threads_p', 'uid' => $this->thread_uid))?>
		
		<?if($this->move_topic):?>
		<form action="<?=$this->url(array('controller' => 'threads', 'action' => 'move'), 'default', true)?>" method="post">
			<div style="float:right; border:1px solid #ddd; padding:5px; background-color:#eee;">
				<p class="form_cell">
					<label for="board_uid"><?=$this->translate->_('post_move_topic')?></label>
						<select name="board_uid" id="board_uid">
							<option value=""><?=$this->translate->_('form_choose')?></option>
							<?if($this->cats_count > 0):?>
								<?foreach($this->cats_res AS $result):?>
									<option disabled="disabled"><?=$this->escape($result['title'])?></option>
									<?if($this->GetBoards($result['uid'])->count() > 0):?>
										<?foreach($this->GetBoards($result['uid'])->toArray() as $bResult):?>
											<option value="<?=$bResult['uid']?>" style="padding-left:20px;"><?=$this->escape($bResult['title'])?></option>
										<?endforeach;?>
									<?endif;?>
								<?endforeach;?>
							<?endif;?>
						</select>
					<br />
					<span><?=$this->translate->_('post_move_topic_d')?></span>
				</p>
				<p><input type="submit" value="<?=$this->translate->_('form_submit')?>" /></p>
			</div>
			<input type="hidden" name="topic_uid" value="<?=$this->thread_uid?>" />
			<br style="clear:both;" />
		</form>
		<?endif;?>
	<?else:?>
		<p class="notice_bad"><?=$this->translate->_('error_thread_query')?></p>
	<?endif;?>
<?endif;?>